#include <iostream>
#include <cmath>
#include <stdlib.h>
#define N 100

//cmmdc = gcd ?

using namespace std;

int min(int elements_a, int elements_b){
    if(elements_a<elements_b)
        return elements_a;
    else
        return elements_b;
}

int gcd(int a, int b){
if ((a%b)==0)
        return b;
    else
        return gcd(b,(a%b));
}

int new_array(int array_a[], int array_b[], int elements_a, int elements_b){
int i;
int elements_c;
float tmp;
elements_c=min(elements_a, elements_b);
int array_c[elements_c];

for(i=0;i<elements_c;i++){
    if(array_a[i] != 0 && array_b[i]!=0){
        array_c[i]=gcd(array_a[i], array_b[i]);}
    else
        array_c[i]=111;
}


for(i=0;i<elements_c;i++)
    cout<<array_c[i]<<" ";
}

void readintVector_A(int array_a[], int elements_a){
for (int i=0; i<elements_a; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_a[i];
	cout<<"\n";}
}

void readintVector_B(int array_b[], int elements_b){
for (int i=0; i<elements_b; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_b[i];
	cout<<"\n";}
}


int main(){
int array_a[N];
int array_b[N];

int elements_a;
int elements_b;

cout<<"Type the number of elements you want in the array A: ";
cin>>elements_a;
readintVector_A(array_a, elements_a);

cout<<"Type the number of elements you want in array B: ";
cin>> elements_b;
readintVector_B(array_b, elements_b);

cout<<"The original array A is ";
for(int i=0; i<elements_a; i++){
	cout<<array_a[i]<<" ";}
cout<<endl;

cout<<"The original array B is ";
for(int i=0; i<elements_b; i++){
	cout<<array_b[i]<<" ";}
cout<<endl;

cout<<"The final array C is: "<<endl;
new_array(array_a, array_b, elements_a, elements_b);


return 0;
}
